import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'provider/time_range_picker_provider.dart';
import 'widget/time_range_picker_browser.dart';

Future<List<int>> showTimeRangePicker(BuildContext context, {List<int> defaultValue}) {
  return Navigator.push<List<int>>(
      context,
      MaterialPageRoute(
        builder: (context) => _TimeRangePicker(
          defaultValue: defaultValue,
        ),
      ));
}

class _TimeRangePicker extends StatefulWidget {
  final List<int> defaultValue;

  const _TimeRangePicker({this.defaultValue});

  @override
  __TimeRangePickerState createState() => __TimeRangePickerState();
}

class __TimeRangePickerState extends State<_TimeRangePicker> {
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (context) => TimeRangePickerProvider(defaultValue: widget.defaultValue),
      child: Scaffold(
        appBar: CenterTitleAppBar(title: '选择时间'),
        body: TimeRangePickerBrowser(),
      ),
    );
  }
}
